// pages/index/schoolCompare/schoolCompare.js
import {
    GetContrastDetail, // 对比详情
} from '../../../api/index'
import Toast from '../../../miniprogram_npm/@vant/weapp/toast/toast'


Page({

  /**
   * 页面的初始数据
   */
  data: {
    totalHeight:0,
    headList: [
      { title: '共所院校' },
      { title: '2024招生专业数（本科-物理）' },
      { title: '2024招生专业数（本科-历史）' },
      { title: '所在地区' },
      { title: '创办时间' },
      { title: '办学性质' },
      { title: '隶属于' },
      { title: '学科层次' },
      { title: '院校类型' },
      { title: '985' },
      { title: '211' },
      { title: '双一流' },
      { title: '院系数' },
      { title: '博士点' },
      { title: '硕士点' },
      { title: '男生占比' },
      { title: '女生占比' },
    ],
    list: [
    {
      date:'2022-04-01',
      name:'李易峰',
      jobNumber:'0957',
      week:'星期一',
      upTime:'08:30:43',
      belowTime:'18:01:56',
      lateTime:'30:43',
      earlyTime:'',
      comment:'',
      one:'',
      two:'',
      three:'',
      four:'',
      five:'',
      six:'',
      seven:'',
      eight:'',
      nine:''
    },
    {
        date:'2022-04-01',
        name:'李易峰',
        jobNumber:'0957',
        week:'星期一',
        upTime:'08:30:43',
        belowTime:'18:01:56',
        lateTime:'30:43',
        earlyTime:'',
        comment:'',
        one:'',
        two:'',
        three:'',
        four:'',
        five:'',
        six:'',
        seven:'',
        eight:'',
        nine:''
      },
      {
          date:'2022-04-01',
          name:'李易峰',
          jobNumber:'0957',
          week:'星期一',
          upTime:'08:30:43',
          belowTime:'18:01:56',
          lateTime:'30:43',
          earlyTime:'',
          comment:'',
          one:'',
          two:'',
          three:'',
          four:'',
          five:'',
          six:'',
          seven:'',
          eight:'',
          nine:''
        },
        {
            date:'2022-04-01',
            name:'李易峰',
            jobNumber:'0957',
            week:'星期一',
            upTime:'08:30:43',
            belowTime:'18:01:56',
            lateTime:'30:43',
            earlyTime:'',
            comment:'',
            one:'',
            two:'',
            three:'',
            four:'',
            five:'',
            six:'',
            seven:'',
            eight:'',
            nine:''
          },
 
 
  ]
  },

 

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.getSystemInfo({
        success:(res)=> {
          this.setData({
            // totalHeight: (res.windowHeight * 2) - 240
            totalHeight: res.windowHeight
          })
        }
      })
      let openid = wx.getStorageSync('openId') || '';
      let reserve1 = options.reserve1
      let reserve2 = options.reserve2
      if (reserve1 == 'one') {
        this._GetContrastDetail({openId:openid,reserve1:'one',reserve2:reserve2},true)
      } else {
        this._GetContrastDetail({openId:openid,reserve1:'all'},true)
      }
      
  },

   // 触底事件
   handleScrollToLower(e){
    if(e.detail.direction == 'bottom') {
      console.log('scroll-view触底事件在这里处理加载下一页数据')
    }
},

// 对比详情
_GetContrastDetail: function (data, isLoading) {
    GetContrastDetail(data, isLoading).then(res => {
        console.log(res)
        let code = res.code;
        if (code == 200) {
            this.setData({
                list:res.data
            })
            this.setData({
                ['headList[' + 0 + '].title']: '共' + res.data.length + '所院校'
            })
        } else {
            Toast(res.msg)
        }
    })
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  onShareTimeline: function (){

},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})